<?php

class Technical_OrderController extends Zend_Controller_Action
{

    public function init(){  
    }
    public function indexAction(){
    }
    
    public function getAction(){
    	$request = $this->getRequest();
    	if ($request->isPost()) {
    		$orderParam = $request->getPost('orderparam');
    		if($orderParam == 'lecturer') {
    			$lecturerDao = new Application_Model_Dao_User();
    			$lecturers = $lecturerDao->getToSelectLecturers();
    			echo json_encode($lecturers);
    		} else if ($orderParam == 'course') {
    			$coursesTypeDao = new Application_Model_Dao_CoursesType();
  				$coursesTypes = $coursesTypeDao->getToSelectClasses();
  				echo json_encode($coursesTypes);
    		}
    	}
    	 



    }
    
    public function addAction()
    {


		$yearDao = new Application_Model_Dao_YearsStudent();
  		$years = $yearDao->getToSelectInformationAboutYear();
  		$this->view->years = $years;

    	$subjectDao = new Application_Model_Dao_Subject();
  		$subjects = $subjectDao->getToSelect();
    	$this->view->subjects = $subjects;
    	
    	
    	$coursesTypeDao = new Application_Model_Dao_CoursesType();
  		$coursesTypes = $coursesTypeDao->getToSelect();
    	$this->view->coursesTypes = $coursesTypes;
  		
    	$form = new Application_Form_Subject();
		$form->appendValidationEngineFiles($this->view);
		$polish = BH_TranslatePL::getPolishTranslation();
		$translate = new Zend_Translate('array', $polish, 'pl');
		$form->setTranslator($translate);
			
		$form->submit->setLabel('Dodaj nowy przedmiot');
		$this->view->SubjectForm = $form;
		$request = $this->getRequest();
		if ($request->isPost()) {
			if ($form->isValid($request->getPost())) {
				$subject = new Application_Model_Entities_Subject();
				$subject->setDesignation( $form->getValue('designation'));
				$subject->setShort( $form->getValue('short'));
				$subjectDao = new Application_Model_Dao_Subject();
				$subjectDao->saveSubject($subject);

				$this->_helper->redirector('add');
			}
		}
    	/*
    	$form->submit->setLabel('Zapisz');
		$this->view->OrderForm = $form;
    	
    	$request = $this->getRequest();
    	if ($request->isPost()) {
    		if ($form->isValid($request->getPost())) {
    			$order = new Application_Model_Entities_Order();
    			$order->setSubject( $form->getValue('subjectID') );
    			$order->setSpeciality( $form->getValue('specialityID') );
    			$order->setNumberWeek( $form->getValue('numberWeek') );
    			$order->setDimensionSemester( $form->getValue('dimensionSemester') );
    			$order->setHourYear( $form->getValue('hourYear') );
    			$order->setHourSemester( $form->getValue('hourSemester') );
    			$order->setYear( $form->getValue('yearID') );
    			$orderDao = new Application_Model_Dao_Order();
    			$orderDao->saveOrder($order);
    		//	$result = Zend_Auth::getInstance()->authenticate($order);
    			//if ($result->isValid()) {
    				$this->_helper->redirector('index');
    			} else {
    				//$form->login->addError('Należy wypełnić wszystkie pola.');
    			}
    		//}
    	}
    }
    */
    }
}
